package org.vectrics.common.html;

import org.apache.ecs.html.Div;
import org.apache.ecs.html.IMG;
import org.apache.log4j.Logger;

public class NameValueTable extends Table {
	private transient final Logger log = Logger.getLogger(this.getClass());
	private String graphicsResourcePath;
	private String cellClass1 = "formBg1";
	private String cellClass2 = "formBg2";
    private String currentCellClass = cellClass1;

	public NameValueTable(String graphicsResourcePath) {
		super();
		this.graphicsResourcePath = graphicsResourcePath;
		this.setWidth("100%");
	}
	
    public void addSepRow(int colSpan) {
	    log.debug("doRender() - function.");
	    Row row = this.addRow();
	    Cell cell = row.addCell();
	    cell.setColSpan(colSpan);

	    IMG clear = new IMG();
	    clear.setSrc(graphicsResourcePath + "cleardot.gif");
	    clear.setWidth(2);
	    clear.setHeight(11);
	    cell.addElement(clear);
	}

    
    public void addNameValueRow(String name, String value) {
	    Row row = this.addRow();
	    Cell cell = row.addCell();
	    cell.setWidth("40%");
	    cell.setClass(currentCellClass);

	    cell.addElement(TextHelper.getFont("stdBoldFont", name));
	    cell = row.addCell();
	    cell.setWidth("60%");

	    row = this.addRow();
	    cell = row.addCell();
	    cell.setColSpan(2);
	    Div div = new Div();
	    div.setClass("fieldDiv");
	    div.addElement(TextHelper.getFont("stdFont", value));
	    cell.addElement(div);
	    
    }
    
    
}
